import {
    ownerList,
    ownerPage,
    ownerAdd,
    ownerUpdate,
    ownerDelete
} from '@/api/base.owner'
export default {
    namespaced: true,
    //数据保存在State中
    state: {
        menu: []
    },
    //对于后台的请求放在actions中
    actions: {
        getOwnerList() {
            return new Promise((resolve, reject) => {
                ownerList().then(
                    res => {
                        resolve(res)
                    }
                )
            })
        },
        //context 对象是vuex框架自己放入到第一个参数,界面上调用时传入的参数,需要放入第二个参数
        getOwnerPage(context, data) {
            return new Promise((resolve, reject) => {
                ownerPage(data).then(
                    res => {
                        resolve(res)
                    }
                )
            })
        },
        addowner(context, data) {
            return new Promise((resolve, reject) => {
                console.log('addowner')
                console.log(data)
                ownerAdd(data).then(
                    resolve()
                )
            })
        },

        updateowner(context, data) {
            return new Promise((resolve, reject) => {
                console.log('updateowner')
                console.log(data)
                ownerUpdate(data).then(
                    resolve()
                )
            })
        },

        deleteowner(context, id) {
            return new Promise((resolve, reject) => {
                ownerDelete(id).then(
                    resolve()
                )
            })
        }
    }
}